#include "Defs.h"
#include "RuleFlag.h"


RuleFlag_T::RuleFlag_T(const char * szName, int iDef, const char * szRootSection, const char * szConfigFile)
	:flag(false)
	,_iDef(iDef)
{
	FillMemory(_szName, sizeof(_szName), 0);
	_snprintf(_szName, sizeof(_szName) - 1, szName);

	flag = GetPrivateProfileInt(szRootSection, _szName, _iDef, szConfigFile) == 1;
}

void RuleFlag_T::ToString(char * szBuffer, unsigned int bufferSize)
{
	unsigned int bufferCursor = 0;

	_snprintf(szBuffer + bufferCursor, bufferSize - 1 - bufferCursor, 
		"# %s=%d\r\n", _szName, flag ? 1 : 0);
	bufferCursor = lstrlen(szBuffer);
}